import datetime
from settings.publicvar import Base
from sqlalchemy.orm import Mapped, mapped_column, relationship
from sqlalchemy import String, ForeignKey
from typing_extensions import Annotated

from views.person.model.person import PersonBaseInfo

int_pk = Annotated[int,mapped_column(primary_key=True)]
date_set = Annotated[datetime.date,mapped_column(nullable=True)]

class Position(Base):
    __tablename__ = 'position'

    id: Mapped[int_pk]
    name_id: Mapped[int] = mapped_column(ForeignKey('personbaseinfo.id'))
    acquisition_method: Mapped[str]
    post_grade: Mapped[str]
    acquisition_date:Mapped[datetime.date]
    hire_date:Mapped[date_set]
    execute_date:Mapped[date_set]
    post_type:Mapped[str]
    mark:Mapped[str] = mapped_column(nullable=True)

    personbase: Mapped[PersonBaseInfo] = relationship(lazy=False, backref='positions')

class SalaryScale(Base):
    __tablename__ = 'salaryscale'

    id: Mapped[int_pk]
    name_id: Mapped[int] = mapped_column(ForeignKey('personbaseinfo.id'))
    salaryscale_level:Mapped[str]
    salaryscale_date:Mapped[date_set]
    salaryscale_type:Mapped[str]
    mark: Mapped[str] = mapped_column(nullable=True)

    personbase: Mapped[PersonBaseInfo] = relationship(lazy=False, backref='salaryscales')


class Setreform(Base):
    __tablename__= 'setreform2006'

    id: Mapped[int_pk]
    name_id: Mapped[int] = mapped_column(ForeignKey('personbaseinfo.id'))
    position_name:Mapped[str]
    position_year_name:Mapped[int]
    setreform_year_number:Mapped[int]
    salaryscale_number:Mapped[int]
    mark:Mapped[str] = mapped_column(nullable=True)

    personbase: Mapped[PersonBaseInfo] = relationship(lazy=False, backref='setreforms')

class SetreformStatistics(Base):
    __tablename__ = 'setreformstatistics2006'

    id: Mapped[int_pk]
    position:Mapped[str]
    position_year_start_number:Mapped[int]
    position_year_end_number: Mapped[int]
    job_year_start_number: Mapped[int]
    job_year_end_number: Mapped[int]
    salaryscale:Mapped[int]  = mapped_column(nullable=True)
    mark:Mapped[str] = mapped_column(nullable=True)